// api.js
export function request(url, method = 'GET', data = {}, headers = {}) {
    return new Promise((resolve, reject) => {
        uni.request({
            url: url,
            method: method,
            data: data,
            header: headers,
            success: (res) => {
                if (res.statusCode === 200) {
                    resolve(res.data);
                } else {
                    reject(res);
                }
            },
            fail: (error) => {
                reject(error);
            }
        });
    });
}
 
export function get(url, data = {}, headers = {}) {
    return request(url, 'GET', data, headers);
}
 
export function post(url, data = {}, headers = {}) {
    return request(url, 'POST', data, headers);
}